/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package radio_station7.gui.util;

import java.awt.Component;
import javax.swing.AbstractCellEditor;
import javax.swing.JSpinner;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;


public class TimeCellEditor extends AbstractCellEditor implements TableCellEditor {

    protected JSpinner spinner;

    public TimeCellEditor() {
        spinner = new JSpinner();
    }

    @Override
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
        spinner.setModel(new javax.swing.SpinnerDateModel(new java.util.Date(0L), new java.util.Date(0L), null, java.util.Calendar.SECOND));
        spinner.setEditor(new javax.swing.JSpinner.DateEditor(spinner, "HH:mm:ss"));
        
        if (value != null)
            spinner.setValue(value);

        return spinner;
    }

    @Override
    public Object getCellEditorValue() {
        return spinner.getValue();
    }
}
